<template>

  <div id="echartsContainer" style="height: 600px"></div>

</template>

<script>

import {getCustomerAddressData} from '@/api/business/statistics'
import echarts from 'echarts'

export default {
  name: "CustomerStatistics",
  mounted() {
    // 这个生命周期才是 页面dom元素渲染周期
    this.getCustomerAddress();
  },
  data() {
    return {}
  },
  methods: {
    getCustomerAddress() {
      getCustomerAddressData().then(res => {
        // 将这个数据渲染到页面上去
        var chartDom = document.getElementById('echartsContainer');
        var myChart = echarts.init(chartDom);
        var option = {
          title: {
            text: '客户地址统计',
            left: 'center'
          },
          tooltip: {
            trigger: 'item'
          },
          legend: {
            orient: 'vertical',
            left: 'left'
          },
          series: [
            {
              name: 'address',
              type: 'pie',
              radius: '50%',
              data: res.data,
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
        };
        option && myChart.setOption(option);
      });
    }
  }

}
</script>

<style scoped>

</style>
